From 83b4f39c44a03e414013836e8ccf59ca7407f097 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Mar 2016 14:40:00 -0700 Subject: [PATCH] Prepare for ARM/FreeBSD/NetBSD nightlies This commit beefs up Cargo's makefiles to support nightly builds of Cargo for multiple platforms. This primarily involves vendoring the logic of how to build OpenSSL for statically linking against Cargo into the Makefiles directly. We'll have to update the version of OpenSSL as releases are made, but we essentially already do that with the normal docker container. The Linux nightlies will still run in the normal dist docker container (a really old CentOS build) and builds for new platforms will happen in the standard linux-cross container we use for other cross builds. The nightly versions of these will produce Cargo tarballs for a whole bunch of platforms to get uploaded. This has been tested in the `alexcrichton/rust-slave-linux-cross:2016-03-17b` docker container for the 3 ARM targets and FreeBSD target. NetBSD will come once rust-lang/rust#32407 lands. --- Cargo.lock | 53 ++++++++++----------- Makefile.in | 103 +++++++++++++++++++++++++++++++++++++---- configure | 22 +++++---- src/etc/dl-snapshot.py | 3 +- src/rustversion.txt | 2 +- src/snapshots.txt | 8 ++++ 6 files changed, 143 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 226b19698..81df93b36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ dependencies = [ "bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "crates-io 0.1.0", "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -18,7 +18,7 @@ dependencies = [ "hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -65,14 +65,14 @@ name = "cmake" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crates-io" version = "0.1.0" dependencies = [ - "curl 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -84,25 +84,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl-sys" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "gcc" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -181,7 +181,7 @@ name = "git2-curl" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,15 +216,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -238,22 +238,22 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.1.36" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libz-sys" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -284,7 +284,7 @@ name = "miniz-sys" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -312,7 +312,7 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -488,3 +488,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" + diff --git a/Makefile.in b/Makefile.in index f534bc50d..ab091ca2f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,9 @@ CFG_RELEASE_NUM=0.10.0 CFG_RELEASE_LABEL= +OPENSSL_VERS=1.0.2g +OPENSSL_SHA256=b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33 + include config.mk ifneq ($(CFG_LOCAL_RUST_ROOT),) @@ -46,6 +49,12 @@ else VERBOSE_FLAG= endif +ifdef CFG_CUSTOM_BUILD_DIR +export CARGO_TARGET_DIR := $(CFG_CUSTOM_BUILD_DIR) +endif + +S := $(CFG_SRC_DIR)/ + export CFG_VERSION export CFG_DISABLE_CROSS_TESTS @@ -81,10 +90,12 @@ endif all: $(foreach target,$(CFG_TARGET),cargo-$(target)) define CARGO_TARGET -cargo-$(1): $$(CARGO) +cargo-$(1): $$(CARGO) target/openssl/$(1).stamp $$(CFG_RUSTC) -V $$(CARGO) --version - $$(CARGO) build --target $(1) $$(OPT_FLAG) $$(VERBOSE_FLAG) $$(ARGS) + $$(CARGO) build --target $(1) \ + --manifest-path $(S)Cargo.toml \ + $$(OPT_FLAG) $$(VERBOSE_FLAG) $$(ARGS) test-unit-$(1): $$(CARGO) @mkdir -p target/$(1)/cit @@ -92,8 +103,8 @@ test-unit-$(1): $$(CARGO) endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) -$(TARGET_ROOT)/snapshot/bin/cargo$(X): src/snapshots.txt - $(CFG_PYTHON) src/etc/dl-snapshot.py $(CFG_BUILD) +$(TARGET_ROOT)/snapshot/bin/cargo$(X): $(S)src/snapshots.txt + $(CFG_PYTHON) $(S)src/etc/dl-snapshot.py $(CFG_BUILD) touch $@ @@ -155,6 +166,76 @@ $(DOC_DIR)/%: src/doc/% @mkdir -p $(@D) cp $< $@ +ifdef CFG_ENABLE_NIGHTLY + +OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64 +OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64 +OPENSSL_OS_i686-unknown-linux-gnu := linux-x32 +OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4 +OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 +OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 +OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64 +OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64 + +OPENSSL_CC_x86_64-unknown-linux-gnu := gcc +OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc +OPENSSL_CC_i686-unknown-linux-gnu := gcc +OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc +OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc +OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc +OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc +OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc +OPENSSL_AR_x86_64-unknown-linux-gnu := ar +OPENSSL_AR_x86_64-unknown-linux-musl := ar +OPENSSL_AR_i686-unknown-linux-gnu := ar +OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar +OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar +OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar +OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar +OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar + +define BUILD_OPENSSL +OPENSSL_INSTALL_$(1) := $$(CFG_BUILD_DIR)/target/openssl/$(1)-install + +target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ + | target/openssl/ + mkdir -p target/openssl/$(1) + tar xf $$< -C target/openssl/$(1) --strip-components 1 + (cd target/openssl/$(1) && \ + CC=$$(OPENSSL_CC_$(1)) \ + AR=$$(OPENSSL_AR_$(1)) \ + ./Configure --prefix=$$(OPENSSL_INSTALL_$(1)) \ + no-dso $$(OPENSSL_OS_$(1)) -fPIC && \ + $(MAKE) -j10 && \ + $(MAKE) install) + touch $$@ + +# variables read by various build scripts to find openssl +cargo-$(1): export OPENSSL_STATIC := 1 +cargo-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1)) +cargo-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib +cargo-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include + +# build libz statically into the cargo we're producing +cargo-$(1): export LIBZ_SYS_STATIC := 1 +endef + +$(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target)))) + +target/openssl/openssl-$(OPENSSL_VERS).tar.gz: | target/openssl/ + curl -o $(@) https://openssl.org/source/openssl-$(OPENSSL_VERS).tar.gz + sha256sum $(@) > $(@).sha256 + test $(OPENSSL_SHA256) = `cut -d ' ' -f 1 $(@).sha256` + +target/openssl/: + mkdir -p $(@) +else +define BUILD_OPENSSL +target/openssl/$(1).stamp: +endef +$(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target)))) +endif + # === Distribution define DO_DIST_TARGET @@ -186,21 +267,23 @@ prepare-image-$(1): $$(IMGDIR_$(1))/share/zsh/site-functions \ $$(IMGDIR_$(1))/etc/bash_completion.d cp $$(TARGET_$(1))/cargo$$(X) $$(IMGDIR_$(1))/bin - cp src/etc/cargo.1 $$(IMGDIR_$(1))/share/man/man1 - cp src/etc/_cargo $$(IMGDIR_$(1))/share/zsh/site-functions/_cargo - cp src/etc/cargo.bashcomp.sh $$(IMGDIR_$(1))/etc/bash_completion.d/cargo - cp README.md LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY \ + cp $(S)src/etc/cargo.1 $$(IMGDIR_$(1))/share/man/man1 + cp $(S)src/etc/_cargo $$(IMGDIR_$(1))/share/zsh/site-functions/_cargo + cp $(S)src/etc/cargo.bashcomp.sh $$(IMGDIR_$(1))/etc/bash_completion.d/cargo + cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \ + $(S)LICENSE-THIRD-PARTY \ $$(IMGDIR_$(1))/share/doc/cargo prepare-overlay-$(1): rm -Rf $$(OVERLAYDIR_$(1)) mkdir -p $$(OVERLAYDIR_$(1)) - cp README.md LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY \ + cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \ + $(S)LICENSE-THIRD-PARTY \ $$(OVERLAYDIR_$(1)) echo "$(CFG_VERSION)" > $$(OVERLAYDIR_$(1))/version $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz: prepare-image-$(1) prepare-overlay-$(1) - sh src/rust-installer/gen-installer.sh \ + sh $(S)src/rust-installer/gen-installer.sh \ --product-name=Rust \ --rel-manifest-dir=rustlib \ --success-message=Rust-is-ready-to-roll. \ diff --git a/configure b/configure index c61a44b60..9f150d2ef 100755 --- a/configure +++ b/configure @@ -366,22 +366,24 @@ done CFG_TARGET=$V_TEMP if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then - err "cargo does not currently support an out-of-tree build dir" + CFG_CUSTOM_BUILD_DIR=$CFG_BUILD_DIR/target + putvar CFG_CUSTOM_BUILD_DIR fi if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then if [ ! -f .cargo/config ]; then mkdir -p .cargo cat > .cargo/config <<-EOF -[target.x86_64-unknown-linux-gnu.openssl] -rustc-flags = "-l static=ssl -l static=crypto -l dl -L /home/rustbuild/root64/lib" -root = "/home/rustbuild/root64" -include = "/home/rustbuild/root64/include" - -[target.i686-unknown-linux-gnu.openssl] -rustc-flags = "-l static=ssl -l static=crypto -l dl -L /home/rustbuild/root32/lib" -root = "/home/rustbuild/root32" -include = "/home/rustbuild/root32/include" +[target.arm-unknown-linux-gnueabi] +linker = "arm-linux-gnueabi-gcc" +[target.arm-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" +[target.armv7-unknown-linux-gnueabihf] +linker = "armv7-linux-gnueabihf-gcc" +[target.x86_64-unknown-freebsd] +linker = "x86_64-unknown-freebsd10-gcc" +[target.x86_64-unknown-netbsd] +linker = "x86_64-unknown-netbsd-gcc" EOF fi fi diff --git a/src/etc/dl-snapshot.py b/src/etc/dl-snapshot.py index c43f47fd6..c44ed3127 100644 --- a/src/etc/dl-snapshot.py +++ b/src/etc/dl-snapshot.py @@ -10,7 +10,8 @@ cksumre = re.compile('^ ([^ ]+) ([^$]+)$') current = None snaps = {} -with open('src/snapshots.txt') as f: +d = os.path.dirname(os.path.dirname(__file__)) +with open(d + '/snapshots.txt') as f: for line in iter(f): line = line.rstrip() m = datere.match(line) diff --git a/src/rustversion.txt b/src/rustversion.txt index b6ebe1778..80feeed05 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-02-12 +2016-03-22 diff --git a/src/snapshots.txt b/src/snapshots.txt index 807739ae9..30ec19c58 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +2016-03-21 + linux-i386 ac401c16ff53e0c51b88707579b4f95d7d4c4763 + linux-x86_64 84266cf626ca4fcdc290bca8f1a74e6ad9e8b3d9 + macos-i386 3550c653db2b8a41fdd7057339c923353081e7b0 + macos-x86_64 0372d52f6d06e3e18c8ffa6f016638b6d082770e + winnt-i386 4bacbd3e0219f424740ce35e74a005b007a552aa + winnt-x86_64 8fc67036c4c76fbfa1d8532d9b9ac923f9060001 + 2016-01-31 linux-i386 7e2f9c82e1af5aa43ef3ee2692b985a5f2398f0a linux-x86_64 4c03a3fd2474133c7ad6d8bb5f6af9915ca5292a -- 2.30.2